﻿using DoNet.Bpmn.IRepostitories;
using DoNet.Bpmn.Models;
using DoNet.Core;

namespace DoNet.Bpmn.Repositories
{
    public class BpmnNodeOutSideAccessConfigRepository : BaseRepository<BpmnNodeOutSideAccessConfig>, IBpmnNodeOutSideAccessConfigRepository
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="serviceProvider"></param>
        public BpmnNodeOutSideAccessConfigRepository(IServiceProvider serviceProvider) : base(serviceProvider)
        { }

        #region 同步方法
        /// <summary>
        /// 同步根据BpmnNodeId
        /// </summary>
        /// <param name="bpmnNodeId"></param>
        /// <returns></returns>
        public BpmnNodeOutSideAccessConfig GetByBpmnNodeId(long bpmnNodeId)
        {
            return Db.Queryable<BpmnNodeOutSideAccessConfig>().Where(x => x.BpmnNodeId == bpmnNodeId).First();
        }
        #endregion 同步方法

        #region 异步方法
        /// <summary>
        /// 异步根据BpmnNodeId
        /// </summary>
        /// <param name="bpmnNodeId"></param>
        /// <returns></returns>
        public async Task<BpmnNodeOutSideAccessConfig> GetByBpmnNodeIdAsync(long bpmnNodeId)
        {
            return await Db.Queryable<BpmnNodeOutSideAccessConfig>().Where(x => x.BpmnNodeId == bpmnNodeId).FirstAsync();
        }
        #endregion 异步方法
    }
}
